/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aaron.platform.view;

import com.aaron.platform.dao.PageInfo;
import com.aaron.platform.entity.*;
import com.aaron.platform.exceptions.EnterpriseNotExistException;
import com.aaron.platform.exceptions.UserSessionException;
import com.aaron.platform.service.IEnterpriseMgr;
import com.aaron.platform.service.IExcelTools;
import com.aaron.platform.service.ILxkrProjectMgr;
import com.aaron.platform.service.LxgxExistsException;
import com.aaron.platform.service.UserSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpSession;
import jxl.read.biff.BiffException;
import jxl.write.WriteException;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

/**
 *
 * @author Administrator
 */
public class LxkrProjectListBean extends DataListBean {

    private static Logger logger = Logger.getLogger(LxkrProjectListBean.class);

    /** 小区名 */
    private String residenceName;

    /** 区域ID */
    private int domainId;

    /** 供应商 */
    private int enterpreseId;

    private ILxkrProjectMgr lxkrProjectMgr;
    
    private IEnterpriseMgr enterpriseMgr;
    
    private IExcelTools excelTools;
    
    private ZdwLxkrProjectInfo currentProjectInfo;
    
    private ZdwLxkrProjectMaterial currentProjectMaterial;
    
    private DataModel materials;
    
    private List<SelectItem> coverTypeList;
    
    private List<SelectItem> advanceTypeList;
    
    private List<SelectItem> materTypeList;
    
    private List<SelectItem> materTypeDetailList;
    
    private List<SelectItem> materUnitList;
    
    /** 1:view 2:edit 3:delete */
    private int currentOperation = 1;

    public LxkrProjectListBean() {
        super();
        this.tableTitle = FacesUtil.getString("table_title_lxkrProjectlist");

        // 删除、编辑、查看操作
        this.deletable = true;
        this.editable = true;
        this.viewable = true;
        this.multiSelectable = true;

        // 设置分页信息
        pagable = true;
        init();
        
    }

    /**
     * 初始化查询条件
     */
    private void init() {
        residenceName = "";
        enterpreseId = 0;
        domainId = 0;
        currentProjectInfo = null;
        currentProjectMaterial = new ZdwLxkrProjectMaterial();
        this.data = new ListDataModel();
        this.materials = new ListDataModel();
        pageInfo = new PageInfo<ZdwLxkrProjectInfo>();
    }

    public void reset() {
        init();
    }

    @Override
    public void queryData() {

        // 设置查询条件
        Properties properties = new Properties();
        if (this.domainId != 0) {
            properties.setProperty(ZdwLxkrProjectInfo.DOMAIN_ID, String.valueOf(this.domainId));
        }
        if (this.enterpreseId != 0) {
            properties.setProperty(ZdwLxkrProjectInfo.ENTERPRISE_ID, String.valueOf(this.enterpreseId));
        }
        if (!StringUtils.isEmpty(this.residenceName)) {
            properties.setProperty(ZdwLxkrProjectInfo.RESIDENCE_NAME, StringUtils.trim(this.residenceName));
        }
        
        pageInfo = lxkrProjectMgr.findByCondition(properties, pageInfo.getStartIndex(), pageInfo.getPageSize());
        logger.info("Query payment list finished.");
        data.setWrappedData(pageInfo.getItems());
    }

    @Override
    public void initColumnHeaders() {
        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "area_name",
                FacesUtil.getString("table_column_area"), false, "10%"));
        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "residence_name",
                FacesUtil.getString("table_column_residencename"), false, "20%"));
        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "advance_type",
                FacesUtil.getString("table_column_advancetype"), false, "15%"));
        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "estimated_investment",
                FacesUtil.getString("table_column_estinvest"), false, "15%"));
        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "enterprise_name",
                FacesUtil.getString("table_column_const_name"), false, "20%"));
//        headerColumns.add(new ColumnType(ColumnType.COLUMN_TEXT, "create_user",
//                FacesUtil.getString("table_column_create_user"), false, "10%"));
    }

    @Override
    public String getColumnValue() {
        String columnName = getColumnName();
        increaseColumnIndex();

        ZdwLxkrProjectInfo obj = (ZdwLxkrProjectInfo) data.getRowData();
//        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        if (columnName.equals("area_name")) {
             return obj.getDomainInfo().getDomainName();
        } else if (columnName.equals("residence_name")) {
            return obj.getResidenceName();
        } else if (columnName.equals("advance_type")) {
            return obj.getDisplayAdvanceType();
        } else if (columnName.equals("estimated_investment")) {
            return String.valueOf(obj.getEstimatedInvest());
        } else if (columnName.equals("enterprise_name")) {
            return this.getSimpleString(obj.getEnterpriseInfo().getEnterpriseName(),15);
        } 
        else {
            return null;
        }
    }

    @Override
    public String editData() {
        currentProjectInfo = (ZdwLxkrProjectInfo) data.getRowData();
        currentProjectInfo = lxkrProjectMgr.findById(currentProjectInfo.getLxkrProjectId());
        materials.setWrappedData(currentProjectInfo.getLxkrProjectMaterials());
        currentOperation = 2;
        return "lxkrProject_input";
    }

    @Override
    public String showDetail() {
        currentProjectInfo = (ZdwLxkrProjectInfo) data.getRowData();
        currentProjectInfo = lxkrProjectMgr.findById(currentProjectInfo.getLxkrProjectId());
        materials.setWrappedData(currentProjectInfo.getLxkrProjectMaterials());
        currentOperation = 1;
        return "lxkrProject_input";
    }
    
    @Override
    public String deleteData() {
        currentProjectInfo = (ZdwLxkrProjectInfo) data.getRowData();
        currentOperation = 3; 
        lxkrProjectMgr.removeLxkrProject(currentProjectInfo);
        queryData();
        return "lxkrProject_search";
    }
    
    public String addMaterial() {
        if (StringUtils.isBlank(currentProjectMaterial.getMaterType()) ||
                StringUtils.isBlank(currentProjectMaterial.getMmaterDetail()) ||
                StringUtils.isBlank(currentProjectMaterial.getMaterUnit()) ||
                currentProjectMaterial.getMaterQuantity() <= 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_material_not_correct");
            return null;
        }
        List<ZdwLxkrProjectMaterial> projectMaterials = (List<ZdwLxkrProjectMaterial>)materials.getWrappedData();
        currentProjectMaterial.setLxkrProjectInfo(currentProjectInfo);
        if (projectMaterials == null) {
            projectMaterials = new ArrayList<ZdwLxkrProjectMaterial>();
            projectMaterials.add(currentProjectMaterial);
            materials.setWrappedData(projectMaterials);
        } else {
            projectMaterials.add(currentProjectMaterial);
        }
        currentProjectMaterial = new ZdwLxkrProjectMaterial();
        return null;
    }
    
    public String deleteMeterial() {
        int rowIndex = materials.getRowIndex();
        List<ZdwLxkrProjectMaterial> projectMaterials = (List<ZdwLxkrProjectMaterial>)materials.getWrappedData();
        projectMaterials.remove(rowIndex);
        return null;
    }
    
    /**
     * 录入新工程
     * @return 进入录入页面
     */
    public String createNewLxkrProject() {
        currentProjectInfo = new ZdwLxkrProjectInfo();
        materials = new ListDataModel();
        currentProjectInfo.setDomainInfo(new ItscDomainInfo());
        currentProjectInfo.setEnterpriseInfo(new FgysEnterprise());
        currentProjectInfo.setLxkrProjectMaterials((List<ZdwLxkrProjectMaterial>)materials.getWrappedData());
        currentProjectInfo.setOrderPro(4);
        currentOperation = 3;
        return "lxkrProject_input";
    }
    
    public String saveLxkrProject() {
        // 判断输入条件
        if (StringUtils.isBlank(currentProjectInfo.getResidenceName())) {
            FacesUtil.addErrorMessage(null, "er_lxkr_residence_name_required");
            return null;
        } else if (currentProjectInfo.getCoverType() == 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_cover_type_required");
            return null;
        } else if (currentProjectInfo.getAdvanceType() == 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_advance_type_required");
            return null;
        } else if (StringUtils.isBlank(currentProjectInfo.getExpansionScope())) {
            FacesUtil.addErrorMessage(null, "er_lxkr_expansion_scope_required");
            return null;
        } else if (currentProjectInfo.getEstimatedInvest() == 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_estimated_inves_required");
            return null;
        } else if (currentProjectInfo.getToRequireDate() == null) {
            FacesUtil.addErrorMessage(null, "er_lxkr_torequire_date_required");
            return null;
        } else if (currentProjectInfo.getToDoneDate() == null) {
            FacesUtil.addErrorMessage(null, "er_lxkr_todone_date_required");
            return null;
        } else if (currentProjectInfo.getStartDate() == null) {
            FacesUtil.addErrorMessage(null, "er_lxkr_start_date_required");
            return null;
        } else if (currentProjectInfo.getDoneDate() == null) {
            FacesUtil.addErrorMessage(null, "er_lxkr_done_date_required");
            return null;
        } else if (StringUtils.isBlank(currentProjectInfo.getContactName())) {
            FacesUtil.addErrorMessage(null, "er_lxkr_contact_name_required");
            return null;
        } else if (StringUtils.isBlank(currentProjectInfo.getContactPhone())) {
            FacesUtil.addErrorMessage(null, "er_lxkr_contact_phone_required");
            return null;
        } else if (currentProjectInfo.getEnterpriseInfo().getEnterpriseId() == 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_construction_enterprise_required");
            return null;
        } else if (materials.getRowCount() <= 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_material_required");
            return null;
        }
        
        //      解决 添加后显示区域及合作单位名称问题
        try {
            // 设置合作单位信息
            FgysEnterprise tempEnterprise = enterpriseMgr.
                    findEnterpriseById(currentProjectInfo.getEnterpriseInfo().getEnterpriseId());
            currentProjectInfo.getEnterpriseInfo().setEnterpriseName(tempEnterprise.getEnterpriseName());  
        } catch (EnterpriseNotExistException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
            
        //去除两端的空格（待定）
        
        // 判断日期逻辑
        if (currentProjectInfo.getToRequireDate().after(currentProjectInfo.getToDoneDate()) || 
                currentProjectInfo.getStartDate().after(currentProjectInfo.getDoneDate())) {
            FacesUtil.addErrorMessage(null, "er_lxkr_date_select_error");
            return null;
        }
        try {
            // 获取用户信息
            HttpSession httpSession = FacesUtil.getClientSession();
            UserSession userSession = (UserSession) httpSession.getAttribute("user");
            currentProjectInfo.setCreateUserName(userSession.getUserInfo().getUserChName());
        } catch (UserSessionException ex) {
            logger.error("Fail to get user session.");
                FacesUtil.addErrorMessage(null, ex.getErrorCode());
            return null;
        }
        
        // 更新材料信息
        currentProjectInfo.setLxkrProjectMaterials((List<ZdwLxkrProjectMaterial>)materials.getWrappedData());
        
        // 添加或更新工程信息
        if (currentOperation == 2) {
            lxkrProjectMgr.updateLxkrProject(currentProjectInfo);
            FacesUtil.addInfoMessage(null, "info_lxkr_project_update_success", currentProjectInfo.getResidenceName());
        } else if (currentOperation == 3) {
            try {
                lxkrProjectMgr.addLxkrProject(currentProjectInfo);
            } catch (LxgxExistsException ex) {
                FacesUtil.addErrorMessage(null, ex.getErrorCode(), currentProjectInfo.getResidenceName());
                return null;
            }
            FacesUtil.addInfoMessage(null, "info_lxkr_project_add_success", currentProjectInfo.getResidenceName());
        }   
         
        queryData();
        return "lxkrProject_search";
    }
    
    /**
     * 返回上一页
     * @return 上一页
     */
    public String toLastPage() {
        return "lxkrProject_search";
    }
    
    public String outputAllProjectSheet() { 
        
        // 设置查询条件
        Properties properties = new Properties();
        if (this.domainId != 0) {
            properties.setProperty(ZdwLxkrProjectInfo.DOMAIN_ID, String.valueOf(this.domainId));
        }
        if (this.enterpreseId != 0) {
            properties.setProperty(ZdwLxkrProjectInfo.ENTERPRISE_ID, String.valueOf(this.enterpreseId));
        }
        if (!StringUtils.isEmpty(this.residenceName)) {
            properties.setProperty(ZdwLxkrProjectInfo.RESIDENCE_NAME, StringUtils.trim(this.residenceName));
        }
        // 查询所有符合条件的数据（不分页）
        List<ZdwLxkrProjectInfo> projectInfos = lxkrProjectMgr.findByCondition(properties);
        logger.info("Query payment list finished.");
        
        // 导出数据
        if (projectInfos == null || projectInfos.size() <= 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_no_data_to_output");
            return null;
        }
        
        try {
            excelTools.outputLxkrProjectTable(projectInfos);
        } catch (IOException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (BiffException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (WriteException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
    
    /** 导出当前页数据 */
    public String outputProjectSheet() {
        
        // 延迟加载在view层被关闭，需要刷新数据
        queryData();
        
        // 未查询数据，提示无数据可导出
        if (data == null) {
            FacesUtil.addErrorMessage(null, "er_lxkr_no_data_to_output");
            return null;
        }
        
        // 导出数据
        List<ZdwLxkrProjectInfo> lxkrProjectInfos = (List<ZdwLxkrProjectInfo>) data.getWrappedData();
        if (lxkrProjectInfos == null || lxkrProjectInfos.size() <= 0) {
            FacesUtil.addErrorMessage(null, "er_lxkr_no_data_to_output");
            return null;
        }
        
        try {
            excelTools.outputLxkrProjectTable(lxkrProjectInfos);
        } catch (IOException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (BiffException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (WriteException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            java.util.logging.Logger.getLogger(LxkrProjectListBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    /**
     * 得到缩略词
     * @param inStr 原字段
     * @param len 最长字段
     * @return 缩略字段
     */
    private String getSimpleString(String inStr, int len) {

        if (StringUtils.isBlank(inStr)) {
            return "";
        }
        int lenStr = inStr.length();
        if (lenStr <= len) {
            return inStr;
        } else {
            StringBuilder sb = new StringBuilder();
            return sb.
                    append(StringUtils.left(inStr, len))
                    .append("...")
                    .toString();
        }
    }

    public int getEnterpreseId() {
        return enterpreseId;
    }

    public void setEnterpreseId(int enterpreseId) {
        this.enterpreseId = enterpreseId;
    }

    public int getDomainId() {
        return domainId;
    }

    public void setDomainId(int domainId) {
        this.domainId = domainId;
    }

    public String getResidenceName() {
        return residenceName;
    }

    public void setResidenceName(String residenceName) {
        this.residenceName = residenceName;
    }

    public void setLxkrProjectMgr(ILxkrProjectMgr lxkrProjectMgr) {
        this.lxkrProjectMgr = lxkrProjectMgr;
    }

    public void setExcelTools(IExcelTools excelTools) {
        this.excelTools = excelTools;
    }

    public ZdwLxkrProjectInfo getCurrentProjectInfo() {
        return currentProjectInfo;
    }

    public void setCurrentProjectInfo(ZdwLxkrProjectInfo currentProjectInfo) {
        this.currentProjectInfo = currentProjectInfo;
    }

    public int getCurrentOperation() {
        return currentOperation;
    }

    public DataModel getMaterials() {
        return materials;
    }
   
    public List<SelectItem> getCoverTypeList() {
        if (this.coverTypeList == null) {
            coverTypeList = new ArrayList<SelectItem>();
            coverTypeList.add(new SelectItem(0, FacesUtil.getString("list_item_default")));
            coverTypeList.add(new SelectItem(1, FacesUtil.getString("list_item_zdw_ftth")));
            coverTypeList.add(new SelectItem(2, FacesUtil.getString("list_item_zdw_fttb")));
            coverTypeList.add(new SelectItem(3, FacesUtil.getString("list_item_zdw_adsl")));
            coverTypeList.add(new SelectItem(4, FacesUtil.getString("list_item_zdw_other")));
        }
        return coverTypeList;
    }

    public List<SelectItem> getAdvanceTypeList() {
        if (this.advanceTypeList == null) {
            advanceTypeList = new ArrayList<SelectItem>();
            advanceTypeList.add(new SelectItem(0, FacesUtil.getString("list_item_default")));
            advanceTypeList.add(new SelectItem(1, FacesUtil.getString("list_item_zdw_kr")));
            advanceTypeList.add(new SelectItem(2, FacesUtil.getString("list_item_zdw_fg")));
        }
        return advanceTypeList;
    }
    
    public List<SelectItem> getMaterTypeList() {
        if (this.materTypeList == null) {
            materTypeList = new ArrayList<SelectItem>();
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_dp")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_wlx")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_fgq")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_gj")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_gl")));
            materTypeList.add(new SelectItem(FacesUtil.getString("list_item_zdw_matertype_dl")));        
        }
        return materTypeList;
    }
    
     public List<SelectItem> getMaterTypeDetailList() {
        if (this.materTypeDetailList == null) {
           materTypeDetailList = new ArrayList<SelectItem>(); 
        }
        return materTypeDetailList;
    }
    
    public void materTypeChanged(ValueChangeEvent event) {
        if (this.materTypeDetailList == null) {
            materTypeDetailList = new ArrayList<SelectItem>();
        }
        materTypeDetailList.clear();
        if (FacesUtil.getString("list_item_zdw_matertype_dp").
                equals(String.valueOf(event.getNewValue())) ){
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_ejfg")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_4x")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_6x")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_12x")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_24x")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dptype_48x")));
        } else if (FacesUtil.getString("list_item_zdw_matertype_fgq").
                equals(String.valueOf(event.getNewValue()))) {
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_fgqtype_1to4")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_fgqtype_1to8")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_fgqtype_1to16")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_fgqtype_1to32")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_fgqtype_1to64")));
        } else if (FacesUtil.getString("list_item_zdw_matertype_gj").
                equals(String.valueOf(event.getNewValue()))) {
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_24")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_48")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_96")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_144")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_288")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gjtype_576")));
        } else if (FacesUtil.getString("list_item_zdw_matertype_gl").
                equals(String.valueOf(event.getNewValue()))) {
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_4")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_6")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_12")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_24")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_48")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_gltype_96")));
        } else if (FacesUtil.getString("list_item_zdw_matertype_dl").
                equals(String.valueOf(event.getNewValue()))) {
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_5d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_10d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_25d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_50d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_100d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_200d")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_dltype_400d")));
        } else if (FacesUtil.getString("list_item_zdw_matertype_wlx").
                equals(String.valueOf(event.getNewValue()))) {
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_default")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_wlxtype_130")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_wlxtype_115")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_wlxtype_150")));
            materTypeDetailList.add(new SelectItem(FacesUtil.getString("list_item_zdw_wlxtype_420")));
        }
    }
    
    public List<SelectItem> getMaterUnitList() {
        if (this.materUnitList == null) {
           materUnitList = new ArrayList<SelectItem>(); 
           materUnitList.add(new SelectItem(FacesUtil.getString("list_item_default")));
           materUnitList.add(new SelectItem(FacesUtil.getString("list_item_zdw_mater_unit_ge")));
           materUnitList.add(new SelectItem(FacesUtil.getString("list_item_zdw_mater_unit_mi")));
        }
        return materUnitList;
    }

    public ZdwLxkrProjectMaterial getCurrentProjectMaterial() {
        return currentProjectMaterial;
    }

    public void setCurrentProjectMaterial(ZdwLxkrProjectMaterial currentProjectMaterial) {
        this.currentProjectMaterial = currentProjectMaterial;
    }

    public void setEnterpriseMgr(IEnterpriseMgr enterpriseMgr) {
        this.enterpriseMgr = enterpriseMgr;
    }    
}
